import Vue from 'vue'
import App from './App.vue'
import router from './router'
// import ElementUI from 'element-ui' // 引入element-ui
// import 'element-ui/lib/theme-chalk/index.css' // 导入css样式
// import './plugins/element.js'
// 图标字体导入
import './assets/fonts/iconfont.css'
import './assets/css/global.css'
import TreeTable from 'vue-table-with-tree-grid'

// 导入富文本编辑区域
import VueQuillEditor from 'vue-quill-editor'

import axios from 'axios'

import nprogress from 'nprogress'

Vue.use(VueQuillEditor)

axios.defaults.baseURL = 'https://www.liulongbin.top:8888/api/private/v1/' // 为axios请求设置根路径
// 在request拦截器中添加进度条
axios.interceptors.request.use(config => { // 设置请求头
  nprogress.start()
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
// 在rensponse拦截器中展示进度条
axios.interceptors.response.use(config => {
  nprogress.done()
  return config
})
Vue.prototype.$http = axios // 挂载原型属性，之后每个Vue组件都可以通过this.$http从而发起axios请求

Vue.component('tree-table', TreeTable)

Vue.filter('dateFormat', function (o) {
  const dt = new Date(o)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

// Vue.use(ElementUI)
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
